#include "gps.h"
#include <sstream>

GPS::GPS(const RobotMap* map) :
    _map(map)
{
	_statusPanel = new QFrame(); 
	_statusPanel->resize(100,50);
	_statusPanel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
// 	_statusPanel->setLineWidth(2);
	
	QLabel* label = new QLabel("Etat du GPS :", _statusPanel) ;
	label->move(5,5);
	
	_posX = new QLabel("Position X : 1", _statusPanel) ;
	_posX->move(10, 20);
	_posX->size().setWidth(150);
	_posY = new QLabel("Position Y : 1", _statusPanel) ;
	_posY->move(10, 35);
	_posY->size().setWidth(150);
}

GPS::~GPS() 
{
	delete _statusPanel ;
}

int GPS::firstValue()
{
	return _map->position().first ;
}

int GPS::secondValue()
{
	return _map->position().second ;
}

void GPS::updateLabels()
{
	std::ostringstream oss;
	std::string truc = "" ;
	oss << firstValue() ;
	truc = "Position X : " + oss.str() ;
	_posX->setText(QString(truc.c_str()));
	oss.str("") ;
	oss << secondValue() ;
	truc = "Position Y : " + oss.str() ;
	_posY->setText(QString(truc.c_str()));
	
	_posX->adjustSize();
	_posY->adjustSize();
}

void GPS::updateDatas()
{
	updateLabels() ;
}